import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:最大子矩阵
 * User: wangxin
 * Date: 2024-08-11
 * Time: 17:16
 */
public class test2 {
    public class Main{


        public static int maxMatrix(int [][]matrix){
            int max=Integer.MIN_VALUE;
            for(int i=0;i<matrix.length;i++){
                max=Math.max(max,process(matrix,i));
            }
            return max;
        }
        //得到从第i列到最后一列的所有子矩阵最大值
        public static int process(int[][] matrix,int firstCol){
            int row=matrix.length;
            int col=matrix[0].length;
            int[]dp=new int[row];
            int max=Integer.MIN_VALUE;
            for(int i=firstCol;i<col;i++){
                //dp更新
                for(int j=0;j<row;j++){
                    dp[j]=dp[j]+matrix[j][i];
                }
                max=Math.max(max,findSubArrayMax(dp));
            }
            return max;
        }
        //求以dp维数组的子数组最大值
        public static int findSubArrayMax(int[] arr){
            int n=arr.length;
            int[] dp=new int[n];
            int max=arr[0];
            dp[0]=arr[0];
            for(int i=1;i<n;i++){
                dp[i]=dp[i-1]<0?arr[i]:dp[i-1]+arr[i];
                max=Math.max(dp[i],max);
            }
            return max;
        }

        public static void main(String[]args){
            Scanner sc=new Scanner(System.in);
            int n=sc.nextInt();
            int[][]matrix=new int[n][n];
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    matrix[i][j]=sc.nextInt();
                }
            }
            System.out.print(maxMatrix(matrix));
        }
    }

}
